import {
  BASE_URL
} from '@/settings'
import request from '@/utils/request'

export function employeeRequireList(companyId) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/listNecessaryModeForApp?companyId=${companyId}`,
    method: 'GET'
  })
}

export function updateEmployeeInfoReq(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/empInfos/updateEmpAllInfo`,
    method: 'put',
    data: data
  }, {
    showToast: false
  })
}

export function loadEmployeeInfoReq(empInfoId, companyId) {
  return request({
    url: `${BASE_URL}/hr/api/v1/empInfos/findEmpInfoRelation/${empInfoId}?companyId=${companyId}`,
    method: 'GET'
  })
}
// /approval/api/v1/approFlowGroups/allCanUseByUser/hr?companyId=43DAC26FD76D412488673C9F7078C783
// 获取公司下员工可用审批
export function loadApprovalsReq() {
  const companyId = uni.getStorageSync('companyId')
  return request({
    url: `${BASE_URL}/approval/api/v1/approFlowGroups/allCanUseByUser/hr?companyId=${companyId}`,
    method: 'GET'
  })
}

// 根据审批流程ID获取流程表单
export function getFlowReq(flow_id) {
  return request({
    url: `${BASE_URL}/approval/api/v1/approFlowForms/allCanUseByFlow/${flow_id}`,
    method: 'GET'
  })
}
// url: `${BASE_URL}/hr/api/v1/userAppros/getFlowProcessByApproInfo`,
// 提交表单获取其他流程信息
export function getFlowProcessByApproInfoReq(data) {
  return request({
    url: `${BASE_URL}/approval/api/v1/userAppros/getFlowProcessByApproInfo`,
    method: 'post',
    data: data
  })
}

// 提交审批
export function submitApprovalReq(data) {
  return request({
    url: `${BASE_URL}/approval/api/v1/userAppros`,
    method: 'post',
    data: data
  })
}

// 查询拥有某公司下员工对应用户及能管理该公司的用户列表
export function loadEmployees() {
  const companyId = uni.getStorageSync('companyId')
  return request({
    url: `${BASE_URL}/hr/api/v1/users/listEmpAndRoleUserInCompany/${companyId}`,
    method: 'GET'
  })
}

// 查询拥有某公司权限的用户列表
export function loadAdmins() {
  const companyId = uni.getStorageSync('companyId')
  return request({
    url: `${BASE_URL}/hr/api/v1/users/listUserHasRoleInCompany/${companyId}`,
    method: 'GET'
  })
}

// 公司角色列表
export function loadRoles() {
  // const companyId = uni.getStorageSync('companyId')
  return request({
    url: `${BASE_URL}/hr/api/v1/permissions/roleList?subjectType=company`,
    method: 'GET'
  })
}

export function loadDepartments() {
  const companyId = uni.getStorageSync('companyId')
  return request({
    url: `${BASE_URL}/hr/api/v1/depInfos/listTree?companyId=${companyId}`,
    method: 'GET'
  })
}

export function loadPositions() {
  const companyId = uni.getStorageSync('companyId')
  return request({
    url: `${BASE_URL}/hr/api/v1/positionInfos/listTree?companyId=${companyId}`,
    method: 'GET'
  })
}

// 查询公司动态表单模块
export function listCompanyModuleCodes(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/listCompanyModuleCodesForEmployee`,
    method: 'GET',
    data: data
  })
}


// 查询公司动态表单员工填写
export function getEmpFieldValue(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/getEmpFieldValue`,
    method: 'GET',
    data
  })
}

// 校验员工删除动态表单字段的值
export function checkEmpFieldValue(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/checkEmpFieldValue`,
    method: 'GET',
    data: data
  })
}

// 员工保存动态表单字段的值
export function saveEmpFieldValue(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/empFieldValue`,
    method: 'post',
    data: data
  })
}


// 员工修改动态表单字段的值
export function empFieldValueEdit(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/empFieldValue`,
    method: 'put',
    data: data
  })
}


// 员工删除动态表单字段的值

export function empFieldValueDet(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/companyNecessaryFields/empFieldValue`,
    method: 'DELETE',
    data: data
  })
}